package com.fsharemobile.adapter;

import java.util.List;

import com.fsharemobile.R;
import com.fsharemobile.model.Files;


import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;

public class MyFileArrayAdapter extends ArrayAdapter<Files> {
	
	Activity context=null;
	List<Files> array= null;
	int layoutId;
	
	static class ViewHolder {
	    public TextView text1;
	    public TextView text2;
	    public TextView text3;
	    public TextView text5;
	    public ImageView image;
	    public CheckBox check;
	  } 

	public MyFileArrayAdapter(Activity context, int resource,
			List<Files> objects) {
		super(context, R.layout.my_item_myfile_layout, objects);
		// TODO Auto-generated constructor stub
		this.context=context;
		this.layoutId= resource;
		this.array= objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view = null;
		if(convertView==null){
			LayoutInflater inflater = context.getLayoutInflater();
			view= inflater.inflate(R.layout.my_item_myfile_layout, null);
			
			final ViewHolder viewHolder = new ViewHolder();
			viewHolder.image = (ImageView) view.findViewById(R.id.imgExplore);
			viewHolder.text1= (TextView) view.findViewById(R.id.txt1);
			viewHolder.text2= (TextView) view.findViewById(R.id.txt2);
			viewHolder.text3 = (TextView) view.findViewById(R.id.txt3);
			viewHolder.text5= (TextView) view.findViewById(R.id.txt5);
			viewHolder.check =  (CheckBox) view.findViewById(R.id.cbExplore);
			viewHolder.check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
				
				@Override
				public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
					// TODO Auto-generated method stub
					Files element= (Files) viewHolder.check.getTag();
					element.setSetSelected(buttonView.isChecked());
					
				}
			});
				
				
		}else{	
		}
			
		return view;
				
	}
	
	

}
